package kr.pfg.applications.captureyourscreen.display
{
	import flash.display.BitmapData;
	import flash.events.MouseEvent;
	import flash.events.NativeDragEvent;
	
	import kr.as3.display.NewWindow;

	public class EditWindow extends NewWindow
	{
		private var _bmd:BitmapData;
		private var editFrame:EditFrame;
		public function EditWindow(windowType:String= "normal", chrome:String="standard", transparent:Boolean=false, resizable:Boolean=true, maximizable:Boolean=true, minimizable:Boolean=true)
		{
			super(windowType, chrome, transparent, resizable, maximizable, minimizable);
			this.editFrame = new EditFrame();
			this.stage.addChild( this.editFrame );
			this.initEvents();
		}
		
		private function initEvents():void
		{
			this.editFrame.dragBar.addEventListener( MouseEvent.MOUSE_DOWN, this.dragStart );
			this.editFrame.addEventListener( NativeDragEvent.NATIVE_DRAG_COMPLETE, this.closeWindow );
		}
		
		public function set bitmap( bmd:BitmapData ):void
		{
			this._bmd = bmd;
			this.editFrame.bitmap = this._bmd;
			this.width = this.editFrame.width;
			this.height = this.editFrame.height;
		}
		
		private function dragStart( e:MouseEvent ):void
		{
			this.startMove();
		}
		
		private function closeWindow( e:NativeDragEvent ):void
		{
			this.close();
		}
		
		public function set fullScreenMode( bool:Boolean ):void
		{
			switch( bool )
			{
				case true :
					this.editFrame.fullScreenMode = true;
					this.editFrame.bg.visible = false;
					this.editFrame.canvas.visible = false;
					this.editFrame.dragBar.visible = false;
					this.editFrame.resizeIcon.visible = false;
					this.editFrame.resizeIconDummy.visible = false;
					break;
					
				case false :
					this.editFrame.fullScreenMode = false;
					this.editFrame.bg.visible = true;
					this.editFrame.canvas.visible = true;
					this.editFrame.dragBar.visible = true;
					this.editFrame.resizeIcon.visible = true;
					this.editFrame.resizeIconDummy.visible = true;
			}
		}
		
	}
}